package com.usian.wemedia.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.usian.model.admin.dtos.NewsAuthDto;
import com.usian.model.media.dtos.WmNewsResultDTO;
import com.usian.wemedia.entity.WmNews;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 自媒体图文内容信息表 Mapper 接口
 * </p>
 *
 * @author usian
 * @since 2022-07-08
 */
public interface WmNewsMapper extends BaseMapper<WmNews> {
    @Select("<script>" +
            "select n.*,u.name authorName from wm_news n JOIN wm_user u ON n.wm_user_id=u.id " +
            "<where>" +
            "<if test=\"newsAuthDto.title!=null and newsAuthDto.title!=''\">" +
            " title like concat('%',#{newsAuthDto.title},'%')" +
            "</if>" +
            "</where>" +
            "</script>")
    IPage<WmNewsResultDTO> selectWmNewsByPage(Page page, @Param("newsAuthDto") NewsAuthDto newsAuthDto);
}
